package org.sofun.subscription.model;

import org.sofun.subscription.enums.DayType;
import org.sofun.subscription.enums.OffsetType;
import org.sofun.subscription.enums.OpenDayOrder;
import org.sofun.subscription.enums.TradeFrequency;

import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * 申购规则参数对象
 */
public class SubscriptionRule {
    
    /**
     * 申购交易频率（必选）
     */
    private TradeFrequency tradeFrequency;
    
    /**
     * 开放日排序方式（必选，默认POSITIVE）
     */
    private OpenDayOrder openDayOrder = OpenDayOrder.POSITIVE;
    
    /**
     * 周期内开放日序号（必选，默认1）
     */
    private Integer openDayIndex = 1;
    
    /**
     * 开放日日类型（必选，默认WORKING_DAY）
     */
    private DayType openDayType = DayType.WORKING_DAY;
    
    /**
     * 募集期结束日偏移量（必选）
     */
    private Integer closeDayOffset;
    
    /**
     * 募集期偏移类型（必选，默认NATURAL_DAY）
     */
    private OffsetType offsetType = OffsetType.NATURAL_DAY;
    
    /**
     * 截止时间（必选，默认15:00）
     */
    private LocalTime cutoffTime = LocalTime.of(15, 0);
    
    /**
     * 第一期募集期起始日（必选）
     */
    private LocalDateTime initialDateTime;
    
    // 构造函数
    public SubscriptionRule() {
    }
    
    public SubscriptionRule(TradeFrequency tradeFrequency, Integer closeDayOffset, LocalDateTime initialDateTime) {
        this.tradeFrequency = tradeFrequency;
        this.closeDayOffset = closeDayOffset;
        this.initialDateTime = initialDateTime;
    }
    
    // Getter和Setter方法
    public TradeFrequency getTradeFrequency() {
        return tradeFrequency;
    }
    
    public void setTradeFrequency(TradeFrequency tradeFrequency) {
        this.tradeFrequency = tradeFrequency;
    }
    
    public OpenDayOrder getOpenDayOrder() {
        return openDayOrder;
    }
    
    public void setOpenDayOrder(OpenDayOrder openDayOrder) {
        this.openDayOrder = openDayOrder;
    }
    
    public Integer getOpenDayIndex() {
        return openDayIndex;
    }
    
    public void setOpenDayIndex(Integer openDayIndex) {
        this.openDayIndex = openDayIndex;
    }
    
    public DayType getOpenDayType() {
        return openDayType;
    }
    
    public void setOpenDayType(DayType openDayType) {
        this.openDayType = openDayType;
    }
    
    public Integer getCloseDayOffset() {
        return closeDayOffset;
    }
    
    public void setCloseDayOffset(Integer closeDayOffset) {
        this.closeDayOffset = closeDayOffset;
    }
    
    public OffsetType getOffsetType() {
        return offsetType;
    }
    
    public void setOffsetType(OffsetType offsetType) {
        this.offsetType = offsetType;
    }
    
    public LocalTime getCutoffTime() {
        return cutoffTime;
    }
    
    public void setCutoffTime(LocalTime cutoffTime) {
        this.cutoffTime = cutoffTime;
    }
    
    public LocalDateTime getInitialDateTime() {
        return initialDateTime;
    }
    
    public void setInitialDateTime(LocalDateTime initialDateTime) {
        this.initialDateTime = initialDateTime;
    }
    
    @Override
    public String toString() {
        return "SubscriptionRule{" +
                "tradeFrequency=" + tradeFrequency +
                ", openDayOrder=" + openDayOrder +
                ", openDayIndex=" + openDayIndex +
                ", openDayType=" + openDayType +
                ", closeDayOffset=" + closeDayOffset +
                ", offsetType=" + offsetType +
                ", cutoffTime=" + cutoffTime +
                ", initialDateTime=" + initialDateTime +
                '}';
    }
}
